import { http } from '@/library/http'

export default {
  namespaced: true,
  state: {
    options: []
  },
  getters: {
    // 经验
    exps (state) {
      return state.options.filter((item) => item.type === 1)
    },
    // 薪资
    moneys (state) {
      return state.options.filter((item) => item.type === 0)
    },
    // 学历
    edus (state) {
      return state.options.filter((item) => item.type === 2)
    }
  },
  actions: {
    getOptions ({ state }) {
      return new Promise((resolve, reject) => {
        if (state.options.length === 0) {
          http.get('admin/zhaopin/options')
            .then((result) => {
              state.options = result.list
              resolve()
            })
            .catch(reject)
        }
      })
    }
  }
}
